import math
a = [1, -2, 3, -2, 5, 1]
cur = 0
ans = -math.inf
for i in range(len(a)):
    if cur < 0:
        cur = a[i]
    else:
        cur += a[i]
    ans = max(ans, cur)
print(ans)
